package lambda05;

import org.junit.Test;

import java.util.function.Consumer;

/**
 * Consumer接口
 *   一般用于只传递参数消费(执行)而不获取结果的操作
 *
 *   @FunctionalInterface
 * public interface Consumer<T> {
 *
 *    void accept(T t);
 *  }
 */
public class ConsumerDemo {
	@Test
	public void test01() {
		Consumer<String> c = str-> System.out.println(str);
		c.accept("abcd");

	}

	@Test
	public void test02() {
		method("def",str-> System.out.println(str.length()));
	}
	public void method(String str,Consumer<String> c) {
		c.accept(str);//String str="def"
		               //Consumer<String> c=new  ConsumerDemo$$Lambda$2();
	}
}
/*
*
*   class ConsumerDemo$$Lambda$1 implements Consumer<String>{
*
*       public void accept(String t){
*            System.out.println(t);
*       }
*   }
*
*
*   class ConsumerDemo$$Lambda$2 implements Consumer<String>{
 *
 *       public void accept(String str){
 *            System.out.println(str.length())
 *       }
 *   }
*
*
* */
